.\""Copyright (c) 2001-2020 Apple Inc. All Rights Reserved.
.\"The contents of this file constitute Original Code as defined in and are 
.\"subject to the Apple Public Source License Version 1.2 (the 'License'). 
.\"You may not use this file except in compliance with the
.\"License. Please obtain a copy of the License at 
.\"http://www.apple.com/publicsource and read it before using this file.
.\"
.\"This Original Code and all software distributed under the License are
.\"distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
.\"EXPRESS OR IMPLIED, AND APPLE
.\"HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY 
.\"WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
.\"QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the 
.\"specific language governing rights and limitations under the License."
.Dd December 22, 2020
.Dt CORE 5
.Os
.Sh NAME
.Nm core
.Nd memory image file format
.Sh SYNOPSIS
.In sys/param.h
.Sh DESCRIPTION
A small number of signals which cause abnormal termination of a process
also cause a record of the process's in-core state to be written
to disk for later examination by one of the available debuggers.
(See
.Xr sigaction 2 . )
This memory image is written to a file named by default
.Pa core.pid ,
where
.Va pid
is the process ID of the process,
in the
.Pa /cores
directory,
provided the terminated process had write permission in the directory,
and the directory existed.
.Pp
The maximum size of a core file is limited by
.Xr setrlimit 2 .
Files which would be larger than the limit are not created.
.Pp
The core file consists of the
.Xr Mach-O 5
header as  described in the
.Aq Pa mach-o/loader.h
file.
The remainder of the core
file consists of various sections described in the
.Xr Mach-O 5
header.
.Sh NOTE
Core dumps are disabled by default under Darwin/macOS.
To re-enable core dumps, do one of the following
.Pp
* For subsequent processes spawned by launchd and their child processes, a privileged user can issue the command
.Bd -literal -offset indent
# launchctl limit core unlimited
.Ed
.Pp
* For susequent processes spawned by a shell, use
.Xr ulimit 1
or
.Xr limit 1
depending upon the shell.
.Bd -literal -offset indent
% ulimit \-c unlimited
.Ed
or
.Bd -literal -offset indent
% limit coredumpsize unlimited
.Ed
.Pp
To disable core dumps, set the limit to 0 using one of the aforementioned ways.
.Sh SEE ALSO
.Xr lldb 1 ,
.Xr setrlimit 2 ,
.Xr sigaction 2 ,
.Xr launchd.conf 5 ,
.Xr launchd.plist 5 ,
.Xr Mach-O 5 ,
.Xr sysctl 8
.Sh HISTORY
A
.Nm
file format appeared in
.At v1 .
